<template>
  <div>
    <p>组件A</p>
    <p>接收到父组件的消息:{{ message }}</p>
    <p>接收到父组件的数字:{{ number }}</p>
    <p>我的零花钱:{{ money }}</p>
    <button @click="increment">增加</button>
    <button @click="decrement">减少</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      money: 100
    }
  },
  props: {
    message: {
      type: String,
      required: true
    },
    number: {
      type: Number,
      default: 0
    }
  },
  methods: {
    increment() {
      this.money = this.money + 1
      this.$emit('update-money', this.money)
    },
    decrement() {
      this.money = this.money - 1
      this.$emit('update-money', this.money)
    }
  }
}
</script>

<style lang="scss" scoped></style>
